"use client"

import { useState } from "react"
import { FileExplorer } from "@/components/file-explorer"
import { Sidebar } from "@/components/sidebar"
import { TopBar } from "@/components/top-bar"

export function DriveLayout() {
  const [currentFolderId, setCurrentFolderId] = useState<number>(0)
  const [searchQuery, setSearchQuery] = useState("")
  const [refreshToken, setRefreshToken] = useState(0)

  const handleUploadSuccess = () => {
    setRefreshToken((token) => token + 1)
  }

  return (
    <div className="flex h-screen bg-background">
      <Sidebar />
      <div className="flex-1 flex flex-col overflow-hidden">
        <TopBar
          searchQuery={searchQuery}
          onSearchChange={setSearchQuery}
          onRefreshRequest={handleUploadSuccess}
          currentFolderId={currentFolderId}
        />
        <FileExplorer
          folderId={currentFolderId}
          onFolderChange={setCurrentFolderId}
          searchQuery={searchQuery}
          refreshKey={refreshToken}
        />
      </div>
    </div>
  )
}
